from building import *
import rtconfig

cwd = GetCurrentDir()
src = Glob('*.c') + Glob('avr/*.c') + Glob('*.cpp')
inc = [cwd]

LOCAL_CCFLAGS = ''
LOCAL_CFLAGS = ''
LOCAL_CXXFLAGS = ''

if rtconfig.PLATFORM == 'gcc' or rtconfig.PLATFORM == 'armclang': # GCC or Keil AC6
    LOCAL_CFLAGS += ' -std=c99'
    LOCAL_CXXFLAGS += ' -std=c++11' # support C++11, like non-static data member initializers
elif rtconfig.PLATFORM == 'armcc': # Keil AC5
    LOCAL_CCFLAGS += ' --gnu -g -W'
    LOCAL_CFLAGS += ' --c99' # cannot use --c99 symbol for C++ files, pertically in Keil
    LOCAL_CXXFLAGS += ' --cpp11' # support C++11

group = DefineGroup('Arduino', src,
                     depend = ['PKG_USING_RTDUINO'],
                     CPPPATH = inc,
                     CPPDEFINES = ['ARDUINO=10819', 'ARDUINO_ARCH_RTTHREAD'],
                     LOCAL_CCFLAGS = LOCAL_CCFLAGS,
                     LOCAL_CFLAGS = LOCAL_CFLAGS,
                     LOCAL_CXXFLAGS = LOCAL_CXXFLAGS)

Return('group')
